 package com.oanda.blackberry.restapi;
 
 public class LimitOrder
 {
   String accountid;
   String symbol;
   int units;
   double price;
   long expiry;
   String optType;
   double optLowerPrice;
   double optHighPrice;
   double optStopLoss;
   double optTakeProfit;
   double optTrailingStop;
   double pipLoc;
 
   public LimitOrder()
   {
   }
 
   public LimitOrder(String accountid, String symbol, int units, double price, long expiry, String optType, double optLowerPrice, double optHighPrice, double optStopLoss, double optTakeProfit, double optTrailingStop, double pipLoc)
   {
     this.symbol = symbol;
     this.units = units;
     this.price = price;
     this.accountid = accountid;
     this.optType = optType;
     this.optLowerPrice = optLowerPrice;
     this.optHighPrice = optHighPrice;
     this.optStopLoss = optStopLoss;
     this.optTakeProfit = optTakeProfit;
     this.optTrailingStop = optTrailingStop;
     this.pipLoc = pipLoc;
   }
 
   public String validate()
   {
     String error = "";
 
     if (this.units < 0) error = "invalid units";
     if (this.price <= 0.0D) error = "invalid price";
 
     if ((this.optLowerPrice != (0.0D / 0.0D)) && ((this.optLowerPrice < 0.0D) || (this.optLowerPrice > this.price))) error = "Error: invalid lower bound";
     if ((this.optHighPrice != (0.0D / 0.0D)) && ((this.optHighPrice <= 0.0D) || (this.optHighPrice < this.price))) error = "Error: invalid upper bound";
 
     if ((this.optTakeProfit != (0.0D / 0.0D)) && (this.optTakeProfit <= 0.0D)) error = "invalid take profit";
     if ((this.optTakeProfit != (0.0D / 0.0D)) && (this.optType.equals("long")) && (this.optTakeProfit < this.price)) error = "invalid take profit";
     if ((this.optTakeProfit != (0.0D / 0.0D)) && (this.optType.equals("short")) && (this.optTakeProfit > this.price)) error = "invalid take profit";
 
     if ((this.optStopLoss != (0.0D / 0.0D)) && (this.optStopLoss <= 0.0D)) error = "invalid stop loss";
     if ((this.optStopLoss != (0.0D / 0.0D)) && (this.optType.equals("long")) && (this.optStopLoss > this.price)) error = "invalid stop loss";
     if ((this.optStopLoss != (0.0D / 0.0D)) && (this.optType.equals("short")) && (this.optStopLoss < this.price)) error = "invalid stop loss";
 
     if ((this.optTrailingStop != (0.0D / 0.0D)) && (this.optTrailingStop <= 0.0D)) error = "invalid trailing stop";
 
     if (((!this.symbol.equalsIgnoreCase("xau/usd")) || (!this.symbol.equalsIgnoreCase("xag/usd"))) && (this.units > 10000000)) error = "invalid units";
     if ((this.symbol.equalsIgnoreCase("xau/usd")) && (this.units > 5000)) error = "invalid units (5000 max)";
     if ((this.symbol.equalsIgnoreCase("xag/usd")) && (this.units > 100000)) error = "invalid units (100,000 max)";
 
     return error;
   }
 
   public String getAccountid() {
     return this.accountid;
   }
 
   public long getExpiry() {
     return this.expiry;
   }
 
   public double getOptHighPrice() {
     return this.optHighPrice;
   }
 
   public double getOptLowerPrice() {
     return this.optLowerPrice;
   }
 
   public double getOptStopLoss() {
     return this.optStopLoss;
   }
 
   public double getOptTakeProfit() {
     return this.optTakeProfit;
   }
 
   public double getOptTrailingStop() {
     return this.optTrailingStop;
   }
 
   public String getOptType() {
     return this.optType;
   }
 
   public double getPrice() {
     return this.price;
   }
 
   public String getSymbol() {
     return this.symbol;
   }
 
   public int getUnits() {
     return this.units;
   }
}

